<template>
  <!-- <router-link to="/"></router-link>          
    <router-link to="/about"></router-link> -->
  <keep-alive>
    <router-view />
  </keep-alive>
</template>
<script>
  export default {
    //状态管理刷新防丢失处理
    created() {
      const _store = this.$store;
      // console.log(_store.state.tagmodules.taglist);
      window.onbeforeunload = function () {
        const { tagmodules, addusermodules } = _store.state;
        sessionStorage.setItem("taglist", JSON.stringify(tagmodules.taglist));
        sessionStorage.setItem("addusermodules",JSON.stringify(addusermodules));
      };
    },
    mounted() {
      const _store = this.$store;
      let taglist = sessionStorage.getItem("taglist");
      let addusermodules = sessionStorage.getItem("addusermodules");
      if (taglist) {
        _store.state.tagmodules.taglist = JSON.parse(taglist);
      }
      if (addusermodules) {
        Object.assign(_store.state.addusermodules,JSON.parse(addusermodules))
      }
      sessionStorage.removeItem("taglist");
      sessionStorage.removeItem("addusermodules");
    },
  };
</script>
<style lang="less">
  html,
  body,
  #app {
    padding: 0px;
    margin: 0px;
    height: 100%;
  }
</style>
